package acceptanceTests.registration;
//

import server.ForumServer;



public class RegistrationImp implements RegistrationInt {

	private boolean _implementedIsRegisteredUser = true;
	private boolean _implementedRegister = true;
	private boolean _implementedLogIn = false;
	private boolean _implementedIsOffline = false;
	private boolean _implementedDeleteRegisterUser = true;
	private boolean _implementedisRegularUser = true;

	private ForumServer _server;

	public RegistrationImp() {
			this._server = ForumServer.getInstance();
	}

	public boolean isImplementedIsRegisteredUser() {
		return _implementedIsRegisteredUser;
	}


	public boolean isImplementedRegister() {
		return _implementedRegister;
	}


	public boolean isImplementedLogIn() {
		return _implementedLogIn;
	}

	public boolean isImplementedIsOffline() {
		return _implementedIsOffline;
	}

	public boolean isImplementedDeleteRegisterUser() {
		return _implementedDeleteRegisterUser;
	}

	public boolean isImplementedisRegularUser() {
		return _implementedisRegularUser;
	}


	public boolean register(String userName, String email, String password) {
		if(userName.length()<2 || userName.length()>20
				|| password.length()<3 || password.length()>20){
		return false;
	}
		return this._server.getUserRepository().addUser(userName, email, password);
	}

	public boolean deleteRegisterUser(String userName) {
		return this._server.getUserRepository().removeUser(userName);
	}


	public boolean isRegularUser(String userName) {
		return (this._server.getUserRepository().getUser(userName)._rank > 0);
	}

	public boolean isRegisteredUser(String userName) {
		return (this._server.getUserRepository().exists(userName));
	}

	public ForumServer getServer() {
		return this._server;
	}

}
